package com.cqc.evevationdrag01;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.cqc.evevationdrag01.view.DragFrameLayout;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    private DragFrameLayout dragFrameLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        DragFrameLayout dragFrameLayout = (DragFrameLayout) findViewById(R.id.dragFrameLayout);
        TextView tv = (TextView) findViewById(R.id.tv);
        TextView tv2 = (TextView) findViewById(R.id.tv2);



//        dragFrameLayout.addDragView(tv);//注意：不是addView(tv);
//        dragFrameLayout.addDragView(tv2);//注意：不是addView(tv);
//            @Override
//            public void onDragDrop(boolean captured) {//captured true:捕获到了事件，拖动中；false:没有捕获到时间，松开了view
//                Log.d(TAG, "captured=" + captured);
//                if (captured) {
//                    // TODO: 拖动中的处理
//                } else {
//                    // TODO: 手松开后的处理
//                }
//            }


        dragFrameLayout.addDragView(tv);
        dragFrameLayout.addDragView(tv2);
        dragFrameLayout.setOnDragDropListener(new DragFrameLayout.OnDragDropListener() {
            @Override
            public void onDragDrop(boolean captured) {
                Log.d(TAG, "captured=" + captured);
                if (captured) {
                    // TODO: 拖动中的处理
                } else {
                    // TODO: 手松开后的处理
                }
            }
        });
    }
}
